use std::sync::Arc;
use std::thread::sleep;
use std::thread::spawn;
use std::time::Duration;

fn main() {
    let v = Arc::new(vec![1, 2, 34, 46, 7]);
    let arc = v.clone();
    let h = spawn(move || {
        for i in 0..5 {
            println!("sub thread:{:?}", arc[i]);
            sleep(Duration::from_secs(1));
        }
    });
    println!("{:?}", v);
    for i in 1..5 {
        println!("main thread: {}", i)
    }
    h.join().unwrap();
}
